Skip to content

fix(libSceLibreSsl): report why RSA_sign fails - #16865

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
AlexWhitehouse:fix/libscelibressl-rsa-sign-errors
Nov 11, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
AlexWhitehouse:fix/libscelibressl-rsa-sign-errors

Conversation

@AlexWhitehouse

Copy link
Copy Markdown
Contributor

What

libSceLibreSsl RSA_sign (NID HohNCzDzBW0) returned 0 on its early failures without queueing an error, so a caller's ERR_get_error saw nothing or an older, unrelated error. This PR makes each implemented failure branch queue what LibreSSL 2.5.4's rsa_sign.c queues through RSAerror (library RSA, function 0xfff). It follows my #16649 (EVP_DecryptFinal_ex) and #16741 (BN_mod_inverse).

Failure Reason
NID_md5_sha1 with a digest length other than 36 131, RSA_R_INVALID_MESSAGE_LENGTH
negative algorithm type (OBJ_nid2obj returns NULL) 117, RSA_R_UNKNOWN_ALGORITHM_TYPE
NID_undef, whose OID has length 0 116, RSA_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD
encoded DigestInfo or MD5+SHA1 larger than RSA_size - RSA_PKCS1_PADDING_SIZE 112, RSA_R_DIGEST_TOO_BIG_FOR_RSA_KEY
  • OBJ error: for a negative type, the OBJ unknown-NID error that OBJ_nid2obj queues first, when the added-object table exists, is kept ahead of the RSA error.
  • Unchanged:
    • custom rsa_sign methods and RSA_private_encrypt callbacks keep their own result, output and errors, with no extra RSA_sign error, as upstream;
    • positive algorithm types outside the implemented digest table still throw;
    • RSA_verify isn't touched.
  • Allocation failure: encoding uses a host vector, so allocation failure still throws instead of queueing ERR_R_MALLOC_FAILURE. The new debt entry records this.

Tested

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

🤖 Generated with Claude Code

Match LibreSSL 2.5.4 rsa_sign.c error publication for implemented early failures, preserving callback dispatch and unsupported paths. Source: https://github.com/libressl/openbsd/blob/2e2c612066aa993717528a0249c15c51128d61cb/src/lib/libcrypto/rsa/rsa_sign.c

Add a separate ctest for reason codes, queue ordering, output preservation, DigestInfo parameters, callback results and success without added errors.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 11146 core/libs/prx/libSceLibreSsl/CMakeLists.txt
docs/dev/debt/libSceLibreSsl.md
PR 11176 core/libs/prx/libSceLibreSsl/CMakeLists.txt
docs/dev/debt/libSceLibreSsl.md
PR 11466 core/libs/prx/libSceLibreSsl/CMakeLists.txt
core/libs/prx/libSceLibreSsl/src/Rsa.cpp
docs/dev/debt/libSceLibreSsl.md
PR 12729 core/libs/prx/libSceLibreSsl/CMakeLists.txt
docs/dev/debt/libSceLibreSsl.md
PR 12730 core/libs/prx/libSceLibreSsl/CMakeLists.txt
docs/dev/debt/libSceLibreSsl.md
PR 13266 core/libs/prx/libSceLibreSsl/CMakeLists.txt
docs/dev/debt/libSceLibreSsl.md
PR 13285 core/libs/prx/libSceLibreSsl/CMakeLists.txt
docs/dev/debt/libSceLibreSsl.md
PR 13546 core/libs/prx/libSceLibreSsl/CMakeLists.txt
docs/dev/debt/libSceLibreSsl.md
PR 13547 core/libs/prx/libSceLibreSsl/CMakeLists.txt
docs/dev/debt/libSceLibreSsl.md
PR 13877 core/libs/prx/libSceLibreSsl/CMakeLists.txt
docs/dev/debt/libSceLibreSsl.md
PR 14115 docs/dev/debt/libSceLibreSsl.md
PR 14212 docs/dev/debt/libSceLibreSsl.md
PR 15278 docs/dev/debt/libSceLibreSsl.md
PR 15279 docs/dev/debt/libSceLibreSsl.md
PR 15280 docs/dev/debt/libSceLibreSsl.md
PR 15281 docs/dev/debt/libSceLibreSsl.md
PR 15737 docs/dev/debt/libSceLibreSsl.md
PR 16683 docs/dev/debt/libSceLibreSsl.md
PR 16697 docs/dev/debt/libSceLibreSsl.md
PR 16716 docs/dev/debt/libSceLibreSsl.md
PR 16722 core/libs/prx/libSceLibreSsl/CMakeLists.txt
docs/dev/debt/libSceLibreSsl.md
PR 16725 docs/dev/debt/libSceLibreSsl.md
PR 16726 core/libs/prx/libSceLibreSsl/CMakeLists.txt
docs/dev/debt/libSceLibreSsl.md
PR 16727 docs/dev/debt/libSceLibreSsl.md
PR 16734 docs/dev/debt/libSceLibreSsl.md
PR 17813 core/libs/prx/libSceLibreSsl/CMakeLists.txt
docs/dev/debt/libSceLibreSsl.md
PR 17961 core/libs/prx/libSceLibreSsl/CMakeLists.txt
docs/dev/debt/libSceLibreSsl.md
PR 18396 core/libs/prx/libSceLibreSsl/CMakeLists.txt
docs/dev/debt/libSceLibreSsl.md

@JJenkx

JJenkx commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Windows check of head 37c6f9b6d9, merged onto main 78976e2657 (6198effe21, clean merge).

Setup: Windows 11 Enterprise 22621, WinLibs GCC 15.2 UCRT, Release. The hosted Windows check does not run these tests on pull requests.

  • guest_libressl_rsa_sign_errors passes in 3 of 3 runs, none skipped.

AI-assisted: yes.

@gabichuuuuu

Copy link
Copy Markdown
Contributor

Ran 37c6f9b6d9 merged on main 302864d on Windows 11 x64 (WinLibs GCC 15.2), ctest -R '^guest_libressl_rsa_sign_errors$' -V: guest_libressl_rsa_sign_errors passed 3/3 runs.

The test target is registered by this PR, so I couldn't run the new test against main's sources, and this doesn't show that the test fails without the fix. It doesn't open a Vulkan device, so the GPU doesn't matter here.

AI-assisted: yes.

@AlexWhitehouse

Copy link
Copy Markdown
Contributor Author

Thanks for the run. The control against main is in the Tested section: keeping this branch and running git checkout origin/main -- core/libs/prx/libSceLibreSsl/src/Rsa.cpp registers the test with the old RSA_sign, and guest_libressl_rsa_sign_errors then fails with RSA_sign error 0x0 expected RSA/fff/131 on both Linux and Windows.

@adriadam10 adriadam10 self-assigned this Nov 11, 2026
@oneandonlydean
oneandonlydean merged commit 13bd1da into boykopovar:main Nov 11, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants